import mockApi from "@/api/mockApi";

export default class departmentApi {
  static departments=[
    {"id":1,"enterpriseId":3,"enterpriseName":"星辰教育集团","departmentName":"人力资源部","departmentDescription":"负责企业人力资源规划、招聘、培训等工作","parentId":1,"parentDepartmentName":"总部","createTime":"2024-07-06 20:43:37","modifyTime":"2024-10-24 20:43:37"},
    {"id":2,"enterpriseId":4,"enterpriseName":"绿源农业有限公司","departmentName":"市场营销部","departmentDescription":"负责市场调研、品牌推广、销售策略制定","parentId":1,"parentDepartmentName":"总部","createTime":"2024-11-14 20:43:37","modifyTime":"2024-04-20 20:43:37"},
    {"id":3,"enterpriseId":4,"enterpriseName":"绿源农业有限公司","departmentName":"产品研发部","departmentDescription":"负责新产品研发、技术创新及现有产品优化","parentId":2,"parentDepartmentName":"市场营销部","createTime":"2024-10-17 20:43:37","modifyTime":"2024-01-17 20:43:37"},
    {"id":4,"enterpriseId":1,"enterpriseName":"阳光科技有限公司","departmentName":"财务部","departmentDescription":"负责企业财务管理、预算编制、会计核算","parentId":2,"parentDepartmentName":"总部","createTime":"2024-02-14 20:43:37","modifyTime":"2024-09-10 20:43:37"},
    {"id":5,"enterpriseId":1,"enterpriseName":"阳光科技有限公司","departmentName":"信息技术部","departmentDescription":"负责企业信息化建设、系统维护及技术支持","parentId":2,"parentDepartmentName":"总部","createTime":"2024-03-20 20:43:37","modifyTime":"2024-03-23 20:43:37"},
    {"id":6,"enterpriseId":2,"enterpriseName":"蓝天环保有限公司","departmentName":"客户服务部","departmentDescription":"负责客户咨询、投诉处理及售后服务","parentId":2,"parentDepartmentName":"总部","createTime":"2024-03-08 20:43:37","modifyTime":"2024-03-24 20:43:37"},
    {"id":7,"enterpriseId":4,"enterpriseName":"绿源农业有限公司","departmentName":"供应链管理部","departmentDescription":"负责供应商管理、采购及物流协调","parentId":3,"parentDepartmentName":"产品研发部","createTime":"2024-09-23 20:43:37","modifyTime":"2024-05-19 20:43:37"}
  ]

  static async save (params) {
    console.log('departmentApi save params', params)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }

  static async find (params) {
    console.log('departmentApi find params', params)
    const response = await mockApi.queryPageSuccessfully(departmentApi.departments)
    return response.data
  }

  static async findById (id) {
    console.log('departmentApi findById id', id)
    let target = {}
    for (let a of departmentApi.departments) {
      if (a.id === id) {
        target = a
      }
    }
    const response = await mockApi.queryByIdSuccessfully(target)
    return response.data
  }

  static async del (id) {
    console.log('departmentApi del id', id)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }
}